home *** CD-ROM | disk | FTP | other *** search
- /* Testing library. */
-
- #include <stdio.h>
-
- #include "testlib.h"
-
- int numtests = 0;
-
- int numerrs = 0;
-
- char *curtestfile = "???";
-
- void
- itesteq(long line, long n1, long n2)
- {
- char buf[100];
-
- if (n1 != n2) {
- sprintf(buf, ": %d != %d", n1, n2);
- errmsg(line, buf);
- }
- ++numtests;
- }
-
- void
- errmsg(long line, const char *msg)
- {
- printf("File \"%s\"; Line %d ### ERROR %s \n", curtestfile, line, msg);
- fflush(stdout);
- ++numerrs;
- }
-
- void
- summary()
- {
- if (numerrs > 0) {
- printf("Failed %d of %d tests.\n", numerrs, numtests);
- } else {
- printf("Passed all %d tests.\n", numtests);
- }
- }
-